<template>
  <div style="margin-top:30px;">
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="编码" prop="code" style="margin-right:15px">
              <el-input v-model="form.code" placeholder="请输入编码" />
            </el-form-item>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-form-item label="状态" prop="status" style="margin-right:15px">
              <compStatus ref="palletStatus" @queryStatus="selectStatus" />
            </el-form-item>
          </div>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="funcCancel">取 消</el-button>
      <el-button type="primary" @click="funcSubmit">确 定</el-button>
    </div>
  </div>
</template>
<script>
import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
import request from '@/utils/request'
Vue.use(VXETable)
import compStatus from './palletStatus.vue'
export default {
  name: 'PalletEdit',
  components: {
    compStatus
  },

  data() {
    return {
      form: {
        code: '',
        status: ''
      },
      rules: {
        code: [
          { required: true, message: '请输入编码', trigger: 'blur' },
          
        ],
        status: [
          { required: true, message: '请输入状态：0闲置,1使用', trigger: 'blur' },
          
        ]
      }
    }
  },
  created() {},
  methods: {
    selectStatus(value) {
      this.form.status = value
    },
    // 获取页面信息
    getInfo(code) {
      request({ url: '/arpa-basic-api/pallet/' + code, method: 'get' }).then(response => {
        this.form = response.data
        this.$refs.palletStatus.setSelectValue(this.form.status)
      })
    },
    // 提交
    funcSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          const data = this.form
          request({ url: '/arpa-basic-api/pallet', method: 'put', params: data }).then(response => {
            this.$message({ message: response.msg, type: 'success' })
            this.$emit('fatherEditMethod')
          })
        } else {
          return false
        }
      })
    },
    // 取消
    funcCancel() {
      this.$emit('fatherCancelMethod', 'edit')
    }

  }
}
</script>
<style lang="scss" scoped>
    .dialog-footer {
        margin:15px 0 15px 0;
        width: 175px;
        float: right;
    }
</style>
